<%--
  Created by IntelliJ IDEA.
  User: YKMZ
  Date: 2022/9/23
  Time: 19:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%-- 1. 引入jquery--%>
<script src="webjars/jquery/3.6.1/dist/jquery.min.js"></script>
<%-- 2. 引入bootstrap的css样式--%>
<link rel="stylesheet" href="webjars/bootstrap/3.4.1/dist/css/bootstrap.min.css">
<%-- 3. 引入bootstrap的js样式--%>
<script src="webjars/bootstrap/3.4.1/dist/js/bootstrap.min.js"></script>
<html>
<head>
    <title>购物列表</title>
    <style>
        .container{
            margin-top: 10px;
        }
        .table{
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <h3>所有购物列表</h3>
                </h3>
            </div>
            <table class="table table-striped table-hover">
                <tr>
                    <td>商品ID</td>
                    <td>商品名称</td>
                    <td>商品单价</td>
                    <td>数量</td>
                    <td>操作</td>
                </tr>
                <c:forEach items="${cart.map}" var="p">
                    <tr>
                        <td>${p.value.product.pid}</td>
                        <td>${p.value.product.pname}</td>
                        <td>${p.value.product.price}</td>
                        <td>${p.value.num}</td>
                        <td>
                            <a href="/cart?cmd=remove&pid=${p.value.product.pid}" class="btn btn-danger btn-sm">移除</a>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <div class="panel-body text-right">
                <a href="/product_list.jsp" class="btn btn-success btn-sm">继续挑选</a>
                <a href="/cart?cmd=clear&pid=${p.value.product.pid}" class="btn btn-danger btn-sm">清空购物车</a>
            </div>
        </div>
    </div>
</body>
</html>
